<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/validate-idnumber.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.validate.custom.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <p align="center"><font size="5" color="black" face="楷体">基本信息</font></p>
    <form action="${ctx }/admin/employee/savep1?id=${n.id}"  class="form-horizontal" method="post">
        <div class="form-group">
            <input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
            <input type="hidden" id="user-id-1" name="id" value="${n.id }" class="form-control">
            <!-- 用户ID -->
            <%--<label class="col-sm-2 control-label">用户ID</label>
            <div class="col-sm-4">

                <input type="text" id="user-id-1" name="id" value="${n.id }" class="form-control">
                <input type="text"  placeholder="请选择用户ID" class="form-control"  id="user-name" name="user.username" value="${n.user.id}"
                       onclick="bring({
                               url:'${ctx}/admin/user/search',
                               name: 'username',
                               idInput: 'user-id',
                               nameInput: 'user-name'
                               })" />

            </div>--%>



            <label class="col-sm-2 control-label">部门</label>
            <%-- <div class="col-sm-4">
                 <input type="text" class="form-control" name="n.department" value="${n.department.name }" >
             </div>--%>
            <div class="col-sm-4">
                <input type="hidden" id="department-id" name="department.id" value="${n.department.id }" class="form-control">
                <input type="text"  placeholder="请选择部门" class="form-control"  id="department-name" name="department.name" value="${n.department.name}"
                       onclick="bring({
                               url:'${ctx}/admin/department/search',
                               name: 'name',
                               idInput: 'department-id',
                               nameInput: 'department-name'
                               })" />
            </div>

            <!-- 岗位 -->
            <label class="col-sm-2 control-label">岗位</label>
            <div class="col-sm-4">
                <select id="position" name="position">
                    <option value ="-1" <c:if test="${n.position==null}">selected</c:if>>...</option>
                    <option value ="前端" <c:if test="${n.position=='前端'}">selected</c:if>>前端</option>
                    <option value ="JAVA" <c:if test="${n.position=='JAVA'}">selected</c:if> >JAVA</option>
                    <option value="安卓"  <c:if test="${n.position=='安卓'}">selected</c:if>>安卓</option>
                    <option value="产品经理"  <c:if test="${n.position=='产品经理'}">selected</c:if>>产品经理</option>
                </select>
<%--                <select  id="position" name="position">
                    <option value ="JAVA" >JAVA</option>
                    <option value ="前端" >前端</option>
                    <option value="安卓"  >安卓</option>
                    <option value="产品经理"  >产品经理</option>
                </select>--%>
            </div>

        </div>
        <div class="form-group">

            <!-- 姓名 -->
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input id="name" placeholder="必填项" type="text" class="form-control" name="name" value="${n.name }">
                <label style="color: red" class="errorClass" id="nameError">${errors.name }</label>
            </div>

            <!-- 出生日期 -->
            <label class="col-sm-2 control-label">出生日期</label>
            <div class="col-sm-4">
                <input id="birth" type="text" placeholder="必填项" class="form-control" name="birth" value="<fmt:formatDate value='${n.birth }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">

            <!-- 性别 -->
            <label class="col-sm-2 control-label">性别</label>
            <div class="col-sm-4">
                <select  name="sex">
                    <option value ="-1" <c:if test="${n.sex=='0'}">selected</c:if> >...</option>
                    <option value ="1" <c:if test="${n.sex=='1'}">selected</c:if>>男</option>
                    <option value ="0" <c:if test="${n.sex=='0'}">selected</c:if> >女</option>
                </select>
            </div>

            <!-- 身高 -->
            <label class="col-sm-2 control-label">身高</label>
            <div class="col-sm-3">
                <input type="text" class="form-control" name="height" value="${n.height }">
            </div>
            <div class="col-sm-1">
                cm
            </div>
        </div>
        <div class="form-group">

            <!-- 体重 -->
            <label class="col-sm-2 control-label">体重</label>
            <div class="col-sm-3">
                <input type="text" class="form-control" name="weight" value="${n.weight }">
            </div>
            <div class="col-sm-1">
                kg
            </div>

            <!-- 籍贯 -->
            <label class="col-sm-2 control-label">籍贯</label>
            <div class="col-sm-4">
                <input id="place" type="text" placeholder="必填项" class="form-control" name="place" value="${n.place }">
            </div>
        </div>
        <div class="form-group">

            <!-- 民族 -->
            <label class="col-sm-2 control-label">民族</label>
            <div class="col-sm-4">
                <input id="nation" type="text" placeholder="必填项" class="form-control" name="nation" value="${n.nation }">
            </div>

            <!-- 联系电话 -->
            <label class="col-sm-2 control-label">联系电话</label>
            <div class="col-sm-4">
                <input id="phone" type="text" placeholder="手机号" class="form-control" name="phone" value="${n.phone }">
                <label style="color: red" class="errorClass" id="phoneError">${errors.phone }</label>
            </div>
        </div>
        <div class="form-group">

            <!-- 身份证号 -->
            <label class="col-sm-2 control-label">身份证号</label>
            <div class="col-sm-4">
                <input id="IDCard" type="text" class="form-control" name="IDCard" value="${n.IDCard }">
                <label style="color: red" class="errorClass" id="IDCardError">${errors.IDCard }</label>
            </div>

            <!-- 毕业学校 -->
            <label class="col-sm-2 control-label">毕业学校</label>
            <div class="col-sm-4">
                <input id="school" type="text" class="form-control" name="school" value="${n.school }">
            </div>
        </div>
        <div class="form-group">

            <!-- 专业 -->
            <label class="col-sm-2 control-label">专业</label>
            <div class="col-sm-4">
                <input id="major" type="text" class="form-control" name="major" value="${n.major }">
            </div>

            <!-- 学历 -->
            <label class="col-sm-2 control-label">学历</label>
            <div class="col-sm-4">
                <select  name="education">
                    <option value ="-1" <c:if test="${n.education==null}">selected</c:if>>...</option>
                    <option value ="0" <c:if test="${n.education=='0'}">selected</c:if> >专科</option>
                    <option value ="1" <c:if test="${n.education=='1'}">selected</c:if>>本科</option>
                    <option value="2"  <c:if test="${n.education=='2'}">selected</c:if>>硕士</option>
                    <option value="3"  <c:if test="${n.education=='3'}">selected</c:if>>博士</option>
                </select>
            </div>
        </div>
        <div class="form-group">

            <!-- 户口所在地 -->
            <label class="col-sm-2 control-label">户口所在地</label>
            <div class="col-sm-4">
                <input id="location" type="text" class="form-control" name="location" value="${n.location }">
            </div>

            <!-- 居住地址 -->
            <label class="col-sm-2 control-label">居住地址</label>
            <div class="col-sm-4">
                <input id="address" type="text" class="form-control" name="address" value="${n.address }">
            </div>
        </div>
        <div class="form-group">

            <!-- 微信号 -->
            <label class="col-sm-2 control-label">微信号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="wechat" value="${n.wechat }">
            </div>

            <!-- 邮箱 -->
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-sm-4">
                <input id="email" type="text" class="form-control" name="email" value="${n.email }">
            </div>
        </div>
        <div class="form-group">

            <!-- 婚姻状况 -->
            <label class="col-sm-2 control-label">婚姻状况</label>
            <div class="col-sm-4">
                <select id="marry"  name="marry">
                    <option value ="0" >未婚</option>
                    <option value ="1" >已婚</option>
                    <option value="2"  >离异</option>
                </select>
            </div>

            <!-- 入职时间 -->
            <label class="col-sm-2 control-label">入职时间</label>
            <div class="col-sm-4">
                <input id="inTime" type="text" class="form-control" name="inTime" value="<fmt:formatDate value='${n.inTime }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>

        <div style="display: none" class="form-group">

            <!-- 员工状态/1.录用/2.停职 -->
            <label class="col-sm-2 control-label">员工状态</label>
            <div class="col-sm-4">
                <select id="select4" name="status">
                    <%--<option value ="0" ></option>--%>
                    <option value ="0" >入职</option>
                    <%--<option value ="2" >转正</option>--%>
                    <%--<option value="3"  >离职</option>--%>
                </select>
            </div>
        </div>

        <div class="form-group">

            <!-- 员工状态/1.录用/2.停职 -->
            <%--<label class="col-sm-2 control-label">员工状态/1.录用/2.停职</label>--%>
            <%--<div class="col-sm-4">--%>
            <%--${enum:detail('EmployeeStatus', 'status', n.status)}--%>
            <%--</div>--%>

        </div>
       <!-- <button type="button" class="sub-btn" >员工信息修改</button>-->

    </form>

    <div class="wrapper wrapper-content animated fadeInRight">
        <p align="center"><font size="5" color="black" face="楷体">紧急联系人</font></p>
        <c:forEach items="${emergency}" var="em" varStatus="idx">
            <form action="${ctx }/admin/emergencyContact/save?id=${em.emid }" id="detail-form" class="form-horizontal" method="post">
                <!--紧急联系人信息-->

                <input type="hidden" id="employee-id1" name="employee.id" value="${em.employee.id }" class="form-control">
                <input type="hidden" id="user-id-2" name="emid" value="${em.emid }" class="form-control">
                <div class="form-group">
                    <!-- 姓名 -->
                    <label class="col-sm-2 control-label">姓名</label>
                    <div class="col-sm-4">
                        <input id="emname" type="text" class="form-control" name="emname" value="${em.emname }">
                    </div>
                    <!-- </div>

                     <div class="form-group">-->
                    <!-- 关系 -->
                    <label class="col-sm-2 control-label">关系</label>
                    <div class="col-sm-4">
                        <input id="relation" type="text" class="form-control" name="relation" value="${em.relation }">
                    </div>
                </div>

                <div class="form-group">
                    <!-- 联系电话 -->
                    <label class="col-sm-2 control-label">联系电话</label>
                    <div class="col-sm-4">
                        <input id="emphone" type="text" placeholder="手机号" class="form-control" name="emphone" value="${em.emphone }">
                        <label style="color: red" class="errorClass" id="emphoneError">${errors.emphone }</label>
                    </div>
                    <!--</div>
                    <div class="form-group">-->
                    <!-- 单位或住址 -->
                    <label class="col-sm-2 control-label">单位或住址</label>
                    <div class="col-sm-4">
                        <input id="emaddress" type="text" class="form-control" name="emaddress" value="${em.emaddress }">
                    </div>
                </div>
             <!--   <input type="submit" value="紧急联系人保存">-->
                <br><br>
            </form>
        </c:forEach>
        <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" style="float: right" onclick="onDeleteEm()"> <i class="fa fa-remove"></i>删除</button>
        <button type="button" class="btn btn-sm btn-outline btn-primary" style="float: right" onclick="addEm()"><i class="fa fa-plus"></i> 新增紧急联系人</button>
        <br><br>

    </div>



    <!--教育经历-->
    <div class="wrapper wrapper-content animated fadeInRight">
        <p align="center"><font size="5" color="black" face="楷体">教育及培训情况</font></p>
        <c:forEach items="${education }" var="n1" varStatus="idx">
            <form action="${ctx }/admin/education/save?id=${n1.edid }" id="detail-form-2" class="form-horizontal" method="post">


                <input type="hidden" id="employee-id-1" name="employee.id" value="${n1.employee.id }" class="form-control">
                <input type="hidden" id="user-id-3" name="edid" value="${n1.edid }" class="form-control">
                <div class="form-group">
                    <!-- 学习起始时间 -->
                    <label class="col-sm-2 control-label">学习起始时间</label>
                    <div class="col-sm-4">
                        <input id="start" type="text" class="form-control" name="start" value="<fmt:formatDate value='${n1.start }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                    </div>
                    <!--  </div>
                     <div class="form-group">-->
                    <!-- 学习结束时间 -->
                    <label class="col-sm-2 control-label">学习结束时间</label>
                    <div class="col-sm-4">
                        <input id="end" type="text" class="form-control" name="end" value="<fmt:formatDate value='${n1.end }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                    </div>
                </div>
                <div class="form-group">
                    <!-- 专业 -->
                    <label class="col-sm-2 control-label">专业</label>
                    <div class="col-sm-4">
                        <input id="edmajor" type="text" class="form-control" name="edmajor" value="${n1.edmajor }">
                    </div>
                    <!-- </div>
                     <div class="form-group">-->
                    <!-- 学历 -->
                    <label class="col-sm-2 control-label">学历</label>

                    <div class="col-sm-4">
                        <select  name="record">
                            <option value ="-1" <c:if test="${n1.record==null}">selected</c:if>>...</option>
                            <option value ="0" <c:if test="${n1.record=='0'}">selected</c:if> >专科</option>
                            <option value ="1" <c:if test="${n1.record=='1'}">selected</c:if>>本科</option>
                            <option value="2"  <c:if test="${n1.record=='2'}">selected</c:if>>硕士</option>
                            <option value="3"  <c:if test="${n1.record=='3'}">selected</c:if>>博士</option>
                        </select>

                    </div>
                </div>
                <div class="form-group">
                    <!-- 证书 -->
                    <label class="col-sm-2 control-label">证书</label>
                    <div class="col-sm-4">
                        <input id="certificate" type="text" class="form-control" name="certificate" value="${n1.certificate }">
                    </div>
                </div>
                <br><br>
            </form>
        </c:forEach>
        <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" style="float: right" onclick="onDeleteEd()"> <i class="fa fa-remove"></i>删除</button>
        <button type="button" class="btn btn-sm btn-outline btn-primary" style="float: right" onclick="addEd()"><i class="fa fa-plus"></i> 新增教育经历</button>
        <br><br>

    </div>


    <!--工作经历-->
    <div class="wrapper wrapper-content animated fadeInRight">
        <p align="center"><font size="5" color="black" face="楷体">工作经历</font></p>
        <c:forEach items="${experience}" var="ex" varStatus="idx">
            <form action="${ctx }/admin/experience/save?id=${ex.exid }" id="detail-form-3" class="form-horizontal" method="post">


                <input type="hidden" id="employee-id-2" name="employee.id" value="${ex.employee.id }" class="form-control">
                <input type="hidden" id="user-id-4" name="exid" value="${ex.exid }" class="form-control">
                <div class="form-group">
                    <!-- 离职原因 -->
                    <label class="col-sm-2 control-label">离职原因</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="reason" value="${ex.reason }">
                    </div>


                    <!-- 单位 -->
                    <label class="col-sm-2 control-label">单位</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="company" value="${ex.company }">
                    </div>
                </div>
                <div class="form-group">
                    <!-- 工作 -->
                    <label class="col-sm-2 control-label">工作</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="work" value="${ex.work }">
                    </div>


                    <!-- 职位 -->
                    <label class="col-sm-2 control-label">职位</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="position1" value="${ex.position1 }">
                    </div>
                </div>
                <div class="form-group">
                    <!-- 工作起始时间 -->
                    <label class="col-sm-2 control-label">工作起始时间</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="exstart" value="<fmt:formatDate value='${ex.exstart }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                    </div>

                    <!-- 工作结束时间 -->
                    <label class="col-sm-2 control-label">工作结束时间</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="exend" value="<fmt:formatDate value='${ex.exend }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                    </div>
                </div>
                <br><br>
            </form>
        </c:forEach>
        <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" style="float: right" onclick="onDeleteEx()"> <i class="fa fa-remove"></i>删除</button>
        <button type="button" class="btn btn-sm btn-outline btn-primary" style="float: right" onclick="addEx()"><i class="fa fa-plus"></i> 新增工作经历</button>
        <br><br>

    </div>


    <!--家庭成员管理-->
    <div class="wrapper wrapper-content animated fadeInRight">
        <p align="center"><font size="5" color="black" face="楷体">家庭成员及主要社会关系</font></p>
        <c:forEach items="${family }" var="fa" varStatus="idx">
        <form action="${ctx }/admin/family/save?id=${fa.faid }" id="detail-form-4" class="form-horizontal" method="post">


            <input type="hidden" id="employee-id" name="employee.id" value="${fa.employee.id }" class="form-control">
            <input type="hidden" id="user-id-5" name="faid" value="${fa.faid }" class="form-control">
            <div class="form-group">
                <!-- 姓名 -->
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input id="faname" type="text" class="form-control" name="faname" value="${fa.faname }">
                </div>

                <!-- 关系 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input id="farelation" type="text" class="form-control" name="farelation" value="${fa.farelation }">
                </div>
            </div>
            <div class="form-group">
                <!-- 联系方式 -->
                <label class="col-sm-2 control-label">联系方式</label>
                <div class="col-sm-4">
                    <input id="contact" placeholder="手机号" type="text" class="form-control" name="contact" value="${fa.contact }">
                    <label style="color: red" class="errorClass" id="contactError">${errors.contact }</label>
                </div>

                <!-- 年龄 -->
                <label class="col-sm-2 control-label">年龄</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="age" value="${fa.age }">
                </div>
            </div>
            <div class="form-group">

                <!-- 工作单位 -->
                <label class="col-sm-2 control-label">工作单位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="facompany" value="${fa.facompany }">
                </div>


                <!-- 职位 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="position2" value="${fa.position2 }">
                </div>
            </div>
            <br><br>
        </form>
        </c:forEach>
        <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" style="float: right" onclick="onDeletefa()"> <i class="fa fa-remove"></i>删除</button>
        <button type="button" class="btn btn-sm btn-outline btn-primary" style="float: right" onclick="addfa()"><i class="fa fa-plus"></i> 新增家庭成员</button>
        <br><br>
        <div align="center">
            <p align="center"><font size="5" color="black" face="楷体">身份证照片</font></p>
            <img src="${n.user.idPicture}" width="400" height="400" alt="" >
            <%--    <br><br><br>

                <a style="font-size: 20px" href="/admin/user/download">下载附件</a>--%>
        </div>
        <br><br>
        <div>
            <p align="center">
                <button id="update1" type="button" class="btn btn-sm btn-outline btn-info" onclick="edit()"><i class="fa fa-address-card"></i> 修改身份证</button>
            </p>
        </div>
        <br><br><br>
        <p align="center">
            <button id="update" type="button" style="font-size: 15px"  class="btn btn-sm btn-outline btn-info" ><i class="fa fa-check"></i>确定修改</button>
        </p>
    </div>
    <%@include file="/common/foot.jsp" %>

    <script type="text/javascript">
        $(function() {
            /*
             * 1. 得到所有的错误信息，循环遍历之。调用一个方法来确定是否显示错误信息！
             */
            $(".errorClass").each(function() {
                showError($(this));//遍历每个元素，使用每个元素来调用showError方法
            });
            /*
             * 3. 输入框得到焦点隐藏错误信息
             */
            $(".form-control").focus(function() {
                clearerr($(this));
                var labelId = $(this).attr("id") + "Error";//通过输入框找到对应的label的id
                $("#" + labelId).text("");//把label的内容清空！
                showError($("#" + labelId));//隐藏没有信息的label

            });
            /*
             * 4. 输入框失去焦点进行校验
             */

            $(".form-control").blur(function() {
                var id = $(this).attr("id");//获取当前输入框的id
                checkInput($(this));
                var funName = "validate" + id.substring(0,1).toUpperCase() + id.substring(1) + "()";//得到对应的校验函数名
                eval(funName);//执行函数调用
            });
        });
        /*
         * 身份证号校验方法
         */
        function validateIDCard() {
            var id = "IDCard";
            var value = validateIdNumber($("#" + id).val());//调用IDCard的校验函数
            /*
             * 1. 非空校验
             */
            if(value==0) {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("身份证号码不能为空！");
                showError($("#" + id + "Error"));
                return false;
            }else if(value==1) {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("");
                showError($("#" + id + "Error"));
                return false;
            }else{
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("请输入有效的身份证号码！");
                showError($("#" + id + "Error"));
                return false;
            }
        }
        /*
         * 身份证号校验方法
         */
        function validatePhone() {
            var id = "phone";
            var val = $("#" + id).val()
            if (val =="") {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("手机号码不能为空！");
                showError($("#" + id + "Error"));
                return false;
            } else {
                var value = mobileValidation(val);//调用IDCard的校验函数
                if (!value) {
                    /*
                     * 获取对应的label
                     * 添加错误信息
                     * 显示label
                     */
                    $("#" + id + "Error").text("请输入有效的手机号码！");
                    showError($("#" + id + "Error"));
                    return false;
                }
            }
        }

        function validateEmphone() {
            var id = "emphone";
            var val = $("#" + id).val()
            if (val =="") {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("手机号码不能为空！");
                showError($("#" + id + "Error"));
                return false;
            } else {
                var value = mobileValidation(val);//调用IDCard的校验函数
                if (!value) {
                    /*
                     * 获取对应的label
                     * 添加错误信息
                     * 显示label
                     */
                    $("#" + id + "Error").text("请输入有效的手机号码！");
                    showError($("#" + id + "Error"));
                    return false;
                }
            }
        }

        function validateContact() {
            var id = "contact";
            var val = $("#" + id).val()
            if (val =="") {
                /*
                 * 获取对应的label
                 * 添加错误信息
                 * 显示label
                 */
                $("#" + id + "Error").text("手机号码不能为空！");
                showError($("#" + id + "Error"));
                return false;
            } else {
                var value = mobileValidation(val);//调用IDCard的校验函数
                if (!value) {
                    /*
                     * 获取对应的label
                     * 添加错误信息
                     * 显示label
                     */
                    $("#" + id + "Error").text("请输入有效的手机号码！");
                    showError($("#" + id + "Error"));
                    return false;
                }
            }
        }


        function showError(ele) {
            var text = ele.text();//获取元素的内容
            if(!text) {//如果没有内容
                ele.css("display", "none");//隐藏元素
            } else {//如果有内容
                ele.css("display", "");//显示元素
            }
        }

        function edit() {
            layer.confirm('确认要修改身份证吗?', {icon: 3, title:'提示'}, function(index){
                location.href="${ctx}/admin/user/idPicture";
            });
        }

        $(document).on("click", ".sub-btn", function () {
            var form = $(this).parents("form");
            form.ajaxSubmit({
                success: function(data) {
                    if (isSuccess(data)) {
                        // reload();
                        location.reload()
                    } else {
                    }
                }
            });
        });

        $(document).on("click", ".sub-btn-del", function () {
            var form = $(this).parents("form");
            form.ajaxSubmit({
                success: function(data) {
                    if (isSuccess(data)) {
                        //reload();
                        location.reload()

                    } else {
                    }
                }
            });
        });
        /*$('#detail-form').submit(function (event) {
            event.preventDefault();
            var form = $(this);
            //普通表单
            $.ajax({
                type: form.attr('method'),
                url: form.attr('action'),
                data: form.serialize()
            }).success(function () {
                //成功提交
            });
            return false;
        }*/
       /* $(document).on("click", "#contactBtn", function () {
            var form = $(this).parents("form");
            form.ajaxSubmit({
                success: function(data) {
                    if (isSuccess(data)) {
                        // reload();
                    } else {
                    }
                }
            });
        });*/
        $(document).on("click", "#update", function () {
            var flag=dosubmit();
            if(flag){
                layer.confirm('确认要修改吗?', {icon: 3, title:'提示'}, function(index){
                    var form1 = $("#user-id").parents("form");
                    form1.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                // reload();
                            } else {
                            }
                        }
                    });

                    var form2 = $("#employee-id1").parents("form");
                    form2.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                // reload();
                            } else {
                            }
                        }
                    });

                    var form3 = $("#employee-id-1").parents("form");
                    form3.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                // reload();
                            } else {
                            }
                        }
                    });

                    var form4 = $("#employee-id-2").parents("form");
                    form4.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                // reload();
                            } else {
                            }
                        }
                    });

                    var form5 = $("#employee-id").parents("form");
                    form5.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                // reload();
                            } else {
                            }
                        }
                    });
                    //location.href="${ctx}/admin/employee/details4";
                    location.href="${ctx}/admin/employee/details4";
                });

            }else{

                alert("有必填项未填写！");
            }
        });


        function onDelete(){
            var id =$("#user-id-1").val();
            var name = document.getElementById("user-id-1").value;
            location.href="${ctx}/admin/employee/delete?ids="+name;
        }

        function onDeleteEm(){
            var s = confirm("确认是否删除");
            if(s ==true){
                var id =$("#user-id-2").val();
                if(id==null || id ==''){
                    return false;
                }
                $.ajax({
                    url:"${ctx}/admin/emergencyContact/delete?ids="+id,
                    data: {
                        ids:id
                    },
                    success: function (data) {
                        window.location.reload();
                    }
                });
            }
        };

           /* layer.confirm('是否确认删除',{
                btn:['确认','取消']},function (index) {
            var id =$("#user-id-2").val();
            var name = document.getElementById("user-id-2").value;
            location.href="${ctx}/admin/emergencyContact/delete?ids="+name;
            });
        }
*/
        function onDetailEm(){
            var id =$("#user-id-2").val();
           /*/!* var name = document.getElementById("sub-btn-det").value;
            location.href="${ctx}/admin/emergencyContact/save1?ids="+name;*!/*/
        }

        function onDeleteEd(){
            var s = confirm("确认是否删除");
            if(s ==true){
                var id =$("#user-id-3").val();
                if(id==null || id ==''){
                    return false;
                }
                $.ajax({
                    url:"${ctx}/admin/education/delete?ids="+id,
                    data: {
                        ids:id
                    },
                    success: function (data) {
                        window.location.reload();
                    }
                });
            }
        };

         /*   layer.confirm('确认是否删除',{
                but:['确认','取消']},function (index) {
            var id =$("#user-id-3").val();
            $.ajax(
                url:"${ctx}/admin/education/delete?ids="+id,
                data:{
                    ids:id
                } ,
            )
            });
        }*/

        function onDetailEd(){
            var id =$("#user-id-2").val();
            var name = document.getElementById("sub-btn-det").value;
            location.href="${ctx}/admin/education/save1?ids="+name;
        }

        function onDeleteEx(){
            var s = confirm("确认是否删除");
            if(s ==true){
                var id =$("#user-id-4").val();
                if(id==null || id ==''){
                    return false;
                }

            $.ajax({
                url:"${ctx}/admin/experience/delete?ids="+id,
                data: {
                    ids:id
            },
            success: function (data) {
                window.location.reload();
            }
            });
            }
        };

        function onDeletefa(){
            var s = confirm("确定删除吗");
            if(s == true){
                var id = $("#user-id-5").val();
                if(id == null || id == ''){
                    return false;
                }
                $.ajax({
                    url: "${ctx}/admin/family/delete?ids="+id,
                    data: {
                        ids:id
                    },
                    success: function(data) {
                        window.location.reload();
                    }
                });
            }
        };




        function addEm() {
            k.layer.add("${ctx}/admin/emergencyContact/detail");
        }

        function addEd() {
            k.layer.add("${ctx}/admin/education/detail");
        }

        function addEx() {
            k.layer.add("${ctx}/admin/experience/detail");
        }

        function addfa() {
            k.layer.add("${ctx}/admin/family/detail");
        }
    </script>

    <script type="text/javascript">

        //检查input
        function checkInput(obj) {
            var val = obj.val();
            if(val == "") {
                //obj.className = "errstyle";
                obj.css("border","#CC0033 1px solid");
                return false;
            } else {
                return true;
            }
        }
        //获取焦点时清除错误
        function clearerr(obj) {
            obj.css("border","");
        }
        //提交校验
        function dosubmit() {
            var name = checkInput($("#name"));
            var birth = checkInput($("#birth"));
            var place = checkInput($("#place"));
            var nation = checkInput($("#nation"));
            var phone = checkInput($("#phone"));
            var IDCard= checkInput($("#IDCard"));
            var school = checkInput($("#school"));
            var education= checkInput($("#education"));
            var address = checkInput($("#address"));
            var location= checkInput($("#location"));
            var email = checkInput($("#email"));
            var marry = checkInput($("#marry"));
            var inTime= checkInput($("#inTime"));
            var emname= checkInput($("#emname"));
            var relation = checkInput($("#relation"));
            var emphone = checkInput($("#emphone"));
            var emaddress = checkInput($("#emaddress"));
            var start = checkInput($("#start"));
            var end = checkInput($("#end"));
            var edmajor = checkInput($("#edmajor"));
            var record = checkInput($("#record"));
            var certificate = checkInput($("#certificate"));
            var faname = checkInput($("#faname"));
            var farelation = checkInput($("#farelation"));
            var contact= checkInput($("#contact"));
            if(name&&birth && place&& nation &&phone&& IDCard&& school&& education&& address&& location&&
            email&& marry&& inTime&& emname&& relation&& emphone&& emaddress&& start&& end&& edmajor&& record&&
                certificate&& faname&& farelation&& contact) {
                //提交表单代码
                return true;
                alert("验证通过,可以提交表单");
            } else {
                return false;
                alert("有必填项未填写，不能提交");
            }
        }
    </script>
</body>
</html>